package org.softee.extractor.sax.helper;

public class NsBinding {
    private static final int NS_ATTRIBUTE_DECL_RESERVE = 50;
    public static final char COLON = ':';
    public static final String XMLNS = "xmlns";

    private final String prefix;
    private final String uri;

    public NsBinding(String prefix, String uri) {
        this.prefix = prefix;
        this.uri = uri;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getUri() {
        return uri;
    }

    public String getQname() {
        StringBuilder sb = new StringBuilder(NS_ATTRIBUTE_DECL_RESERVE);
        sb.append(XMLNS);
        if (!prefix.isEmpty()) {
            sb.append(COLON).append(prefix);
        }
        return sb.toString();
    }

    @Override
    public String toString() {
        return  getPrefix() + "=>" + getUri();
    }
}